import os.path
import time
from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()
url = 'file:///' + os.path.abspath('html') + '/注册实例.html'
driver.get(url)

time.sleep(2)
#点击alert
btn_list = driver.find_elements(By.ID, 'alert')
btn_list[0].click()

time.sleep(2)
#点击确定
alter = driver.switch_to.alert
alter.accept()

driver.quit()